/* Copyright (c) 2009 - 2010 98Labs Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.sbal89.map.server;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.*;

@SuppressWarnings("serial")
public class MapGeneratorServlet extends HttpServlet {
	private Logger log = Logger.getLogger(this.getClass().getName());
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String key = req.getParameter("key");
		String type = "";
		String name = req.getServletPath();
		if (name.toUpperCase().indexOf("PR")>-1) {
			type = "pr";
		} else if (name.toUpperCase().indexOf("VP")>-1) {
			type = "vp";
		} else if (name.toUpperCase().indexOf("SN")>-1) {
			type = "sn";
		} else if (name.toUpperCase().indexOf("PL")>-1) {
			type = "pl";
		} else if (name.toUpperCase().indexOf("TM")>-1) {
			type = "tm";
		}
		log.info(req.getRequestURL().toString());
		req.setAttribute("type", type);
		req.setAttribute("key", key);
		String view = "WEB-INF/jsp/index.jsp";
		if (type.equals("tm")) {
			view = "WEB-INF/jsp/tmview.jsp";
		}
		req.getRequestDispatcher(view).include(req, resp);
	}
}
